<!DOCTYPE html>
<html lang="en">
<head>
    <meta name="viewport" content="width=device-width, target-densitydpi=high-dpi" />
    <title>Title</title>
    <link rel="stylesheet" href="/js/bootstrap/css/bootstrap.min.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/plugins/pinglun/jquery.comment.js"></script>
    <script src="/js/bootstrap/js/bootstrap.bundle.min.js"></script>
    <script src="/js/plugins/jquery-form/jquery.form.js"></script>
    <script src="/js/common.js"></script>

    <style>
        .mytextarea{
            width: 280px;
            height: 100px;
        }
    </style>
    <script>
        var arr=[];

        //初始化数据

        /*var arr = [
            {id:1,img:"./images/img.jpg",replyName:"dafei",beReplyName:"dafei",content:"我觉得很好",time:"2019-01-18 11:42:53",address:"深圳",osname:"",browse:"谷歌",replyBody:[]},
            {id:2,img:"./images/img.jpg",replyName:"想想",beReplyName:"阿紫",content:"到菜市场买菜",time:"2019-01-18 10:42:53",address:"深圳",osname:"",browse:"谷歌",replyBody:[{id:3,img:"",replyName:"帅大叔",beReplyName:"匿名",content:"来啊，我们一起吃鸡",time:"2017-10-17 11:42:53",address:"",osname:"",browse:"谷歌"}]},
            {id:3,img:"./images/img.jpg",replyName:"阿紫",beReplyName:"张松",content:"心里后悔极了。",time:"2019-01-18 13:42:53",address:"深圳",osname:"win10",browse:"谷歌",replyBody:[]}
        ];*/

        $(function(){

            var user = JSON.parse(sessionStorage.getItem('user'));
            var sourceId = user.id;
            var travelId = getParams().id;

            var html = '';
            $.get("/travelDiscusses",{travelId:travelId},function (data) {
                $.each(data,function (index, item) {
                    console.log(item);
                    html += '<div class="comment">' +
                        '            <img class="img-circle" src="'+item.img+'" style="width: 50px">' +
                        '            <p style="color: #ffd350">'+item.replyName+'</p>' +
                        '            <p>'+item.content+'</p>' +
                        '            时间: <spn style="text-align: right">'+item.time+'</spn>' +
                        '        </div>'
                 });
                $(".comment").append(html);
            });
            $(".comment-list").addCommentList({data:arr,add:""});
            $("#comment").click(function(){
                var obj = new Object();
                obj.img=user.headImgUrl;
                obj.replyName=user.nickName;
                obj.content=$("#content").val();
                obj.browse=user.place;
                obj.osname="苹果X";
                obj.replyBody="";
                $(".comment-list").addCommentList({data:[],add:obj});

                $.ajax({
                    type: "post",
                    url: "/travelDiscusses",
                    data: {travelId:travelId, sourceId:sourceId, content:(obj.content), type:0},
                    success: function(msg){

                    }
                });
            });

        })
    </script>
    <style type="text/css">
        .my{
            background:url(/jquery-SearchBar20160307/img/666.jpg);
        }
    </style>

</head>
<body >
<div class="my">
<br>
<br>
<br>
<div class="container">
    <form action="/hotel/list" method="get" id="editForm">
        <div class="commentbox">
            <textarea name="content" placeholder="来说几句吧......" class="mytextarea" id="content" style="width: 100%;height: 100px;"></textarea>
            <div class="btn btn-info pull-right" id="comment">评论</div>
        </div>
        <div class="comment">

        </div>

    </form>
    <div class="comment-list">
    </div>
</div>
</div>
</body>
</html>